//
//  UIBarButtonItem.swift
//  webo
//
//  Created by apple on 2016/11/12.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit

extension UIBarButtonItem{

    convenience init(title: String="", imgName: String , target: Any?, action: Selector?) {
        let btn = UIButton()
        
        btn.setTitle(title, for: .normal)
        btn.setTitleColor(UIColor.darkGray, for: .normal)
        btn.setTitleColor(UIColor.orange, for: .selected)
        
        btn.setImage(UIImage.init(named: imgName), for: .normal)
        btn.setImage(UIImage.init(named: "\(imgName)"+"_highlighted"), for: .highlighted)
        
        if let ac = action {
            btn.addTarget(target, action: ac, for: .touchUpInside)
        }
        
        btn.sizeToFit()
        self.init()
       self.customView = btn
    }
    
    
    
    

}
